Aupyom was mainly designed so it is really easily to modify the pitch ant time-scale of sounds. It has been created in the Poppy-project context where robots are used as educational tools. Interactivity was thus a key feature.
In this notebook, you will see:
First, we load sounds into the sampler (please see this notebook for details).
In [ ]:
from aupyom import Sampler, Sound
from aupyom.util import example_audio_file
sampler = Sampler()
audio_file = example_audio_file()
s1 = Sound.from_file(audio_file)
Start playing sound:
In [ ]:
sampler.play(s1)
You can directly change the pitch of any sound directly via a property:
In [ ]:
s1.pitch_shift = 3
Note that you can modify the pitch while the sounds is played.
You can also decrease the pitch:
In [ ]:
s1.pitch_shift = -2
You can "reset" the pitch to its base value:
In [ ]:
s1.pitch_shift = 0
You can also speed-up or slow down sound using the stretch_factor property.
For instance, if you want to double the speed by 2x:
In [ ]:
s1.stretch_factor = 2.0
You can also slow it down:
In [ ]:
s1.stretch_factor = 0.5
And to reset to its initial play speed:
In [ ]:
s1.stretch_factor = 1.0
You can use the notebook widgets to create an interface and easily modify sounds:
In [ ]:
def modify_sound(pitch, stretch):
s1.pitch_shift = pitch
s1.stretch_factor = stretch
In [ ]:
from ipywidgets import interact, FloatSlider
sampler.play(s1)
interact(modify_sound,
pitch=FloatSlider(min=-10, max=10, value=0, step=0.5),
stretch=FloatSlider(min=0.1, max=10, value=1.0, step=0.1));
In [ ]: